package y_2025.m03.d21.t02;
import java.util.Date;

public class Account {
    private int id;                // 账号码
    private double balance;        // 账号余额
    private Date dateCreated;      // 账号创建日期

    // 无参构造函数
    public Account() {
        this.id = 0;
        this.balance = 0.0;
        this.dateCreated = new Date(); // 默认当前时间
    }

    // 提取金额方法
    public void withDraw(double amount) {
        if (amount <= 0) {
            System.out.println("提取金额必须大于0");
        } else if (amount > balance) {
            System.out.println("余额不足，无法提取");
        } else {
            balance -= amount;
            System.out.println("成功提取: " + amount);
        }
    }

    // 存入金额方法
    public void deposit(double amount) {
        if (amount <= 0) {
            System.out.println("存入金额必须大于0");
        } else {
            balance += amount;
            System.out.println("成功存入: " + amount);
        }
    }

    // Getter方法
    public int getId() {
        return id;
    }

    public double getBalance() {
        return balance;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    // 打印账号信息
    public void printAccountInfo() {
        System.out.println("账号信息:");
        System.out.println("账号码: " + id);
        System.out.println("余额: " + balance);
        System.out.println("创建日期: " + dateCreated);
    }
}